import { Component, OnInit } from '@angular/core';
import { ApiService } from '../api/api.service';
import { ApiUrl } from '../api/ApiUrl';
import { AnswerVO } from '../vo/Answervo';
import { Router } from '@angular/router';
import { CompanyVO } from '../vo/CompanyVO';
import { ToastController } from '@ionic/angular';
import { UserVO } from '../vo/UserVO';
import { ActivatedRoute } from '@angular/router';
import { VisitVO } from '../vo/VisitVO';
import { VisitFileVO } from '../vo/VisitFileVO';
@Component({
  selector: 'app-visitdetail',
  templateUrl: './visitdetail.page.html',
  styleUrls: ['./visitdetail.page.scss'],
})
export class VisitdetailPage implements OnInit {
  orgitems: CompanyVO[] = [];
  orgitem: CompanyVO;
  ccompanylinkname: string;
  ccompanylinkphone: string;
  corgname: string;
  cbankcode: string;
  dvisitdate: string;
  icompanytype: string;
  inature: number;
  cnow: string;
  cadd: string;
  isolve: number;
  creason: string;
  clast: string;
  item: VisitVO;
  userItem: UserVO;
  iid: string;
  ccompanytype: string;
  flist: VisitFileVO[];
  constructor(private toastController: ToastController, public api: ApiService, private router: Router,
    public activatedRoute: ActivatedRoute) { }

  ngOnInit() {
    this.iid = this.activatedRoute.snapshot.paramMap.get('iid');
    this.getOne();
  }
getOne() {
  this.api.getItem<VisitVO>(ApiUrl.getOneVisit, { 'id': this.iid }).subscribe(response => {

    if (response === null) {
      console.log('没有数据返回');
      return;
    }
    console.log(response);
     this.item = response;
     this.dvisitdate = this.item.dvisitdate;
     this.corgname = this.item.ccompany;
     this.cbankcode = this.item.cbankcode;
     this.ccompanytype = this.item.ccompanytype;
     this.ccompanylinkname = this.item.ccompanylinkname;
     this.ccompanylinkphone = this.item.ccompanylinkphone;
     this.inature = this.item.inature;
     this.cnow = this.item.cnow;
     this.cadd = this.item.cadd;
     this.isolve = this.item.isolve;
     this.creason = this.item.creason;
     this.clast = this.item.clast;
     this.flist = this.item.flist;
     for (let i = 0; i < this.flist.length; i++) {
        this.flist[i].curl = ApiUrl.visitUrl + this.flist[i].curl;
     }
  }, () => {
    console.log('出错了');
  });
}
}
